function validation()
{
                var fname=0;
                var email=0;
                var pass=0;
                var recaptcha=0;
                var gender=0;
                var agree=0;
                var must=1;
                var error=0;
                $('.error').html("");

                $.post("ajax/registration_validation.php", {email: $('#email').val(), recaptcha_challenge_field: $('#captcha_challenge_field').val(), recaptcha_response_field: $('#captcha_response').val()}, function(data){
                var splited_data = data.split("_");
                //ic, im, ie, ee
                for(var i=0; i<splited_data.length; ++i )
                {
                      //ic=invalid captcha, captcha code is invalid
                      if(splited_data[i]=='ic')
                      {
                                recaptcha=1;
                                error=1;
                                $('#recaptcha-error').html("Please enter the characters shown above");
                                //Recaptcha.reload();
                                getCaptcha();
                      }
                      //ie = invalid email, when email id is invalid
                      if(splited_data[i]=='ie')
                      {
                                email=1;
                                error=1;
                                $('#email').val("");
                                $('#email-error').html("Please enter a valid Email address");
                      }
                      if(splited_data[i]=='ee')
                      {
                                email=1;
                                error=1;
                                $('#email').val("");
                                $('#email-error').html("Email you entered is already register");
                      }
                   
                }
               
                // password checking                
                if($('#password').val().length<6)
                {
                    pass=1;
                    error=1;
                    $('#password').val("");
                    $('#password-error').html("Please enter a valid password with minimum of 6 characters");
                }
                //first name checking
                if($('#first-name').val()=='' || $('#first-name').val()=='First Name' )
                {
                    fname=1;
                    error=1;
                    $('#first-name-error').html("Please enter your First Name");
                    $('#first-name').val("");
                }
                //last name checking
                if($('#last-name').val()=='' || $('#last-name').val()=='Last Name' )
                {
                    lname=1;
                    error=1;
                    $('#last-name-error').html("Please enter your Last Name");
                    $('#last-name').val("");
                }
            
                if(error==0)
                $('#general_registration').submit();
                });


}
            